package com.sskj.aikeeper.presenter;


import android.os.MessageQueue;

import com.lzy.okgo.model.Response;
import com.sskj.aikeeper.bean.BannerNoticeBean;
import com.sskj.aikeeper.hangqing.fragment.HomeFragment;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.CoinBean;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;

/**
 * @author Hey
 * Create at  2019/06/25
 */
public class HomePresenter extends BasePresenter<HomeFragment> {

    public void getTopData(boolean showLoading) {
        httpService.getTopData()
                .tag(this)
                .execute(new JsonCallBack<HttpData<BannerNoticeBean>>(showLoading ? this : null) {
                    @Override
                    public void onSuccess(Response<HttpData<BannerNoticeBean>> response) {
                        mView.getTopDataOK(response.body().getData());
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }

    public void getHangqingData() {
        httpService.getHangqingData("")
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<CoinBean>>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<List<CoinBean>>> response) {
                        mView.getHangqingDataOK(response.body().getData());
                    }
                });
    }
}
